<template>
    <el-drawer title="我是标题" :visible.sync="dialogVisible" :with-header="false" class="demand_box" size='50%' @close="resetForm()">
        <div class="flexbox flexcolumn height_100">
            <div class="demand_head flexbox flexcenter flexbetween">
                <span class="demand_title">时段数据：{{queryInfo.time}}</span>
                <span class="icon_btn icon_btn_32" @click="resetForm()"><img src="@/assets/img/close_check.svg" alt=""></span>
            </div>
            <div class="demand_center flex" v-loading="loading" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)">
                <el-table :data="tableData" class="com_table" height="100%">
                    <el-table-column prop="advertiser_name" label="账户名称" min-width="160">
                    </el-table-column>
                    <el-table-column prop="stat_cost" label="总消耗" width="120">
                    </el-table-column>
                    <el-table-column prop="pay_order_amount" label="总转化销售额" width="150">
                    </el-table-column>
                    <el-table-column prop="prepay_and_pay_order_roi" label="总ROI" width="100">
                    </el-table-column>
                    <el-table-column prop="segmentation_cost" label="时段消耗" width="120">
                    </el-table-column>
                    <el-table-column prop="segmentation_gmv" label="时段转化销售额" width="150">
                    </el-table-column>
                    <el-table-column prop="segmentation_roi" label="时段ROI" width="100">
                    </el-table-column>
                </el-table>
            </div>
            <div class="demand_footer flexbox flexcenter">
                <el-pagination background layout="total, prev, pager, next,sizes" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="queryInfo.page" :page-size="queryInfo.limit" :page-sizes="[20, 50, 100, 200]" :total="total">
                </el-pagination>
            </div>
        </div>
    </el-drawer>
</template>

<script>
export default {
    name: "",
    data() {
        return {
            loading: false,
            dialogVisible: false,
            queryInfo: {
                template_id: "",
                template_advertiser_id:'',
                time:'',
                during:'',
                page: 1,
                limit: 20,
                day:"",
            },
            tableData: [],
            total: 0,
        };
    },
    created() {
        
    },
    methods: {
        getData(data){
            this.dialogVisible = true
            this.queryInfo.template_id = data.template_id
            this.queryInfo.template_advertiser_id = data.template_advertiser_id
            this.queryInfo.time = data.time
            this.queryInfo.during = data.during
            this.queryInfo.day = data.day
            this.getDataList(1)
        },

        //获取账户详情
        async getDataList(page) {
            this.queryInfo.page = page;
            this.loading = true;
            const { data: res } = await this.$http.post(
                "adminapi/tiktokboard/duringAdvertiserCount",
                this.queryInfo
            );
            if (res.code !== 200) {
                this.loading = false;
                this.$message.error(res.msg);
                return;
            } else {
                this.loading = false;
                this.tableData = res.data.list;
                this.total = res.data.count;
            }
        },

        // 关闭重置表单
        resetForm() {
            this.tableData = [];
            this.dialogVisible = false;
        },

        // 每页显示多少条数据
        handleSizeChange(val) {
            this.queryInfo.limit = val;
            this.getDataList(1);
        },
        // 当前页切换
        handleCurrentChange(val) {
            this.queryInfo.page = val;
            this.getDataList(val);
        },
    },
    components: {},
};
</script>


<style scoped>
</style>
